package com.lekang.web.util;

import lombok.Data;

/**
 * @ClassName R
 * @Description TODO
 * @Author wangjinyuan
 * @Date 2025年07月31日 18:59
 * @Version 1.0
 */
@Data
public class R {
    private int code;
    private String msg;
    private Object data;
    public static R ok(){
        R r=new R();
        r.setCode(200);
        r.setMsg("操作成功");
        return r;
    }
    public static R ok(String msg){
        R r=new R();
        r.setCode(200);
        r.setMsg(msg);
        return r;
    }
    public static R ok(Object data){
        R r=new R();
        r.setCode(200);
        r.setMsg("操作成功");
        r.setData(data);
        return r;
    }
    public static R fail(){
        R r=new R();
        r.setCode(201);
        r.setMsg("操作失败");
        return r;
    }
    public static R fail(String msg){
        R r=new R();
        r.setCode(201);
        r.setMsg(msg);
        return r;
    }
    public static R fail(Object data){
        R r=new R();
        r.setCode(201);
        r.setMsg("操作失败");
        r.setData(data);
        return r;
    }
    public static R error(Object data){
        R r=new R();
        r.setCode(202);
        r.setMsg("网络异常，请重试");
        r.setData(data);
        return r;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
